﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TBM.Core
{
    public class Date
    {
        static public string ToText(DateTime date)
        {
            TimeSpan time = DateTime.Now - date;
            double minutes = time.TotalMinutes;

            if (minutes < 1) return "刚才";
            if (minutes < 60) return String.Format("{0} 分钟前", (int)minutes);
            if (time.TotalHours < 24) return string.Format("{0} 小时前", (int)time.TotalHours);

            return string.Format("{0} 天前", (int)time.TotalDays);
        }
    }
}
